package com.cbs.android.xinzhiapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.cbs.android.component.log.L;
import com.cbs.android.component.weather.weatherinterface.WeatherHandler;
import com.cbs.android.component.weather.weatherinterface.entity.Forecast;
import com.cbs.android.component.weather.weatherinterface.entity.Weather;
import com.cbs.android.component.weather.xinzhi.Xinzhi;

public class MainActivity extends AppCompatActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		Xinzhi xinzhi = new Xinzhi(this);
		xinzhi.getForecastByCityName("江苏常州", new WeatherHandler() {
			@Override
			public void onForecast(Forecast forecast) {
				L.e("11111111111111111111111", forecast.getCityName());
				for (Weather weather : forecast.getWeathers()) {
					L.e("11111111111111111111111", weather.getTimestamp() + "");
					L.e("11111111111111111111111", weather.getTemperatureMin() + "");
					L.e("11111111111111111111111", weather.getTemperatureMax() + "");
					L.e("11111111111111111111111", weather.getWeatherType() + "");
					L.e("11111111111111111111111", weather.getWindDirection() + "");
					L.e("11111111111111111111111", weather.getWindLevel() + "");
					L.e("11111111111111111111111", weather.getAqi() + "");
					L.e("11111111111111111111111", weather.getPm25() + "");
					L.e("11111111111111111111111", weather.getPrecipitation() + "");
				}
			}

			@Override
			public void onError(String s) {
				L.e("222222222222222222222222", "22222222222222222222222222222");
			}
		});
//		xinzhi.getForecast(31.810382, 119.992879, new WeatherHandler() {
//			@Override
//			public void onForecast(Forecast forecast) {
//				L.e("11111111111111111111111", forecast.getCityName());
//				for (Weather weather : forecast.getWeathers()) {
//					L.e("11111111111111111111111", weather.getTimestamp() + "");
//					L.e("11111111111111111111111", weather.getTemperatureMin() + "");
//					L.e("11111111111111111111111", weather.getTemperatureMax() + "");
//					L.e("11111111111111111111111", weather.getWeatherType() + "");
//					L.e("11111111111111111111111", weather.getWindDirection() + "");
//					L.e("11111111111111111111111", weather.getWindLevel() + "");
//					L.e("11111111111111111111111", weather.getAqi() + "");
//					L.e("11111111111111111111111", weather.getPm25() + "");
//					L.e("11111111111111111111111", weather.getPrecipitation() + "");
//				}
//			}
//
//			@Override
//			public void onError(String s) {
//				L.e("222222222222222222222222", "22222222222222222222222222222");
//			}
//		});
	}
}
